package cn.bonoon.kernel.web.handlers.loader;

import java.lang.reflect.Field;
import java.util.List;

import cn.bonoon.handler.impl.StandardAutoManager;
import cn.bonoon.kernel.events.ReadEvent;
import cn.bonoon.kernel.support.models.Item;
import cn.bonoon.kernel.support.searcher.Finder;
import cn.bonoon.kernel.web.annotations.AutoDataLoader;

/**
 * <pre>
 * 主要用于combobox控件的加载数据；
 * 自动加载数据使用注解:{@link cn.bonoon.kernel.web.annotations.AutoDataLoader AutoDataLoader}
 * 
 * 所使用的数据为{@link cn.bonoon.kernel.support.models.Item Item}
 * </pre>
 * @author jackson
 * @see BaseComboAutoLoaderHandler
 * @see ComboAutoLoaderHandler
 * @see AbstractAutoLoaderHandler
 * 
 * @see ComboTreeAutoLoaderHandler
 * @see ComboTreeAjaxAutoLoaderHandler
 * @see ComboGridAutoLoaderHandler
 */
public class ComboBoxAutoLoaderHandler extends BaseComboAutoLoaderHandler{

	public ComboBoxAutoLoaderHandler(StandardAutoManager manager, AutoDataLoader loader, Field field) throws Exception {
		super(manager, loader, field);
	}
	
	@Override
	protected List<Item> __parseResult(Finder finder, ReadEvent event) {
		if(isMultiple()){
			return finder.items(selectFields, new SelectedFilter(event));
		}
		return finder.items(selectFields);
	}
}
